import router from '@router/index.js'

router.beforeEach((to, from, next) => {

    // console.log('to-->',to)
    // console.log('from-->',from)

    const sign = cookie.getCookie('sign');
    if (sign && to.path === '/login') {
        next('/mine')
    }
    if (to.meta.loginAuth && !sign) {
        next({
            path: '/login',
            query: { redirect: to.path }
        })
    } else {
        Object.keys(to.params).map((key,i) => {
            to.meta[key] = to.params[key]
        })
        next({
            query: to.query,
        });
    }
})
